package com.ylsk.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ylsk.common.annotation.Log;
import com.ylsk.common.core.controller.BaseController;
import com.ylsk.common.core.domain.AjaxResult;
import com.ylsk.common.enums.BusinessType;
import com.ylsk.system.domain.SysApkPackage;
import com.ylsk.system.service.ISysApkPackageService;
import com.ylsk.common.utils.poi.ExcelUtil;
import com.ylsk.common.core.page.TableDataInfo;

/**
 * apk包管理Controller
 *
 * @author ysy
 * @date 2024-01-24
 */
@RestController
@RequestMapping("/system/apkPackage")
public class SysApkPackageController extends BaseController
{
    @Autowired
    private ISysApkPackageService sysApkPackageService;

    /**
     * 查询apk包管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:apkPackage:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysApkPackage sysApkPackage)
    {
        startPage();
        List<SysApkPackage> list = sysApkPackageService.selectSysApkPackageList(sysApkPackage);
        return getDataTable(list);
    }

    /**
     * 导出apk包管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:apkPackage:export')")
    @Log(title = "apk包管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysApkPackage sysApkPackage)
    {
        List<SysApkPackage> list = sysApkPackageService.selectSysApkPackageList(sysApkPackage);
        ExcelUtil<SysApkPackage> util = new ExcelUtil<SysApkPackage>(SysApkPackage.class);
        util.exportExcel(response, list, "apk包管理数据");
    }

    /**
     * 获取apk包管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:apkPackage:query')")
    @GetMapping(value = "/{apkPackageId}")
    public AjaxResult getInfo(@PathVariable("apkPackageId") Long apkPackageId)
    {
        return success(sysApkPackageService.selectSysApkPackageByApkPackageId(apkPackageId));
    }

    /**
     * 新增apk包管理
     */
    @PreAuthorize("@ss.hasPermi('system:apkPackage:add')")
    @Log(title = "apk包管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysApkPackage sysApkPackage)
    {
        return toAjax(sysApkPackageService.insertSysApkPackage(sysApkPackage));
    }

    /**
     * 修改apk包管理
     */
    @PreAuthorize("@ss.hasPermi('system:apkPackage:edit')")
    @Log(title = "apk包管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysApkPackage sysApkPackage)
    {
        return toAjax(sysApkPackageService.updateSysApkPackage(sysApkPackage));
    }

    /**
     * 删除apk包管理
     */
    @PreAuthorize("@ss.hasPermi('system:apkPackage:remove')")
    @Log(title = "apk包管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{apkPackageIds}")
    public AjaxResult remove(@PathVariable Long[] apkPackageIds)
    {
        return toAjax(sysApkPackageService.deleteSysApkPackageByApkPackageIds(apkPackageIds));
    }
}
